// 引入Layout组件
import Layout from "@/layout";

// 常量路由
export const constantRoutes = [
  // 注册登录的路由
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  // 注册404的路由
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },
  // 注册的是首页的路由
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index"),
        meta: { title: "首 页", icon: "dashboard" },
      },
    ],
  },
];
// 异步路由
export const asyncRoutes = [
  // 权限相关模块
  {
    name: "Acl",
    path: "/acl",
    component: Layout,
    redirect: "/acl/user/list",
    meta: {
      title: "权限管理",
      icon: "el-icon-lock",
    },
    children: [
      {
        name: "User",
        path: "user/list",
        component: () => import("@/views/acl/user"),
        meta: {
          title: "用户管理",
        },
      },
      {
        name: "Role",
        path: "role/list",
        component: () => import("@/views/acl/role"),
        meta: {
          title: "角色管理",
        },
      },
      {
        name: "RoleAuth",
        path: "role/auth/:id",
        component: () => import("@/views/acl/role/roleAuth"),
        meta: {
          activeMenu: "/acl/role/list",
          title: "角色授权",
        },
        hidden: true,
      },
      {
        name: "Permission",
        path: "permission/list",
        component: () => import("@/views/acl/permission"),
        meta: {
          title: "菜单管理",
        }
      }
    ]
  },

  // 商品管理模块
  {
    name: "Product",
    path: "/product",
    component: Layout,
    redirect: "/product/category/list",
    meta: { title: "商品管理", icon: "el-icon-s-shop" },
    children: [
      // 注册分类管理路由
      {
        name: "Category",
        path: "category/list",
        component: () => import("@/views/product/category"),
        meta: { title: "分类管理" },
      },
      // 注册品牌管理路由
      {
        name: "Trademark",
        path: "trademark/list",
        component: () => import("@/views/product/trademark"),
        meta: { title: "品牌管理" },
      },
      // 注册平台属性管理路由
      {
        name: "Attr",
        path: "attr/list",
        component: () => import("@/views/product/attr"),
        meta: { title: "平台属性管理" },
      },
      // 注册SPU管理路由
      {
        name: "Spu",
        path: "spu/list",
        component: () => import("@/views/product/spu"),
        meta: { title: "SPU管理" },
      },
      // 注册SKU管理路由
      {
        name: "Sku",
        path: "sku/list",
        component: () => import("@/views/product/sku"),
        meta: { title: "SKU管理" },
      },
    ],
  }
]

// 暴露任意路由
export const anyRoutes = { path: "*", redirect: "/404", hidden: true };
